/*
 * Copyright (c) 2020 hebeiyiliuba.com
 * All rights reserved.
 *
 */
package org.jeecg.modules.third.jg.report.freight.information.constant.enums;

import com.google.common.collect.Maps;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 河北省平台上报单据类型
 *
 * @author duanlikao
 * @created 2020/12/31
 */
@Getter
@AllArgsConstructor
@NoArgsConstructor
public enum ReportDocTypeEnum {

    REPORT_DOC_TYPE_WLHY_YD("WLHY_YD1001", "电子运单" ,1),
    //-----安徽特殊需求，分3段上传 YD YD2 YD3----------------
    REPORT_DOC_TYPE_WLHY_YD1("WLHY_YD1001", "电子运单1" ,101),
    REPORT_DOC_TYPE_WLHY_YD2("WLHY_YD1002", "电子运单2" ,102),
    REPORT_DOC_TYPE_WLHY_YD3("WLHY_YD1003", "电子运单3" ,103),
    //----------------------------------------------------
    REPORT_DOC_TYPE_WLHY_ZJ("WLHY_ZJ1001", "资金流水单" ,2),
    REPORT_DOC_TYPE_WLHY_JZ("WLHY_JZ1001", "资金流水单" ,201),
    REPORT_DOC_TYPE_WLHY_CL("WLHY_CL1001", "车辆基本信息" ,3),
    REPORT_DOC_TYPE_WLHY_JSY("WLHY_JSY1001", "驾驶员信息",4),
    REPORT_DOC_TYPE_WLHY_QY("WLHY_QY1001", "企业信息",5),
    REPORT_DOC_TYPE_WLHY_WZCX("WLHY_WZ1001", "驾驶员位置信息",6),
    REPORT_DOC_TYPE_WLHY_WZ("WLHY_WZ1001", "位置信息",601),
    REPORT_DOC_TYPE_WLHY_WZCX1("WLHY_JSYWZ1001", "驾驶员位置信息",7),
    REPORT_DOC_TYPE_WLHY_FJ1001("WLHY_FJ1001", "附件资料信息",8),
    REPORT_DOC_TYPE_WLHY_CYR("WLHY_CYR1001", "实际承运人基本信息",9),
    //-----------------------宁夏驾驶员位置信息上传WLHY_POS-----------------------------
    REPORT_DOC_TYPE_WLHY_NX_POS("WLHY_POS", "位置信息上传",10),
    REPORT_DOC_TYPE_WLHY_YDGC("WLHY_YDGC1001", "挂车信息补传单",11),
    ;

    private String code;
    private String msg;
    private int code1;

    private static Map <String, ReportDocTypeEnum> codeMap = Maps.newHashMap();

    public String getCode() {
        return this.code;
    }

    public String getDesc() {
        return this.msg;
    }

    public int getCode1() {
        return this.code1;
    }

    public static String getMsg(String code) {
        return codeMap.containsKey(code) ? codeMap.get(code).getDesc() : StringUtils.EMPTY;
    }
    public static int getCode1(String code) {
        return codeMap.containsKey(code) ? codeMap.get(code).getCode1() : 0;
    }

    public static boolean isValid(String code) {
        return codeMap.containsKey(code);
    }

    static {
        for (ReportDocTypeEnum status : ReportDocTypeEnum.values()) {
            codeMap.put(status.getCode(), status);
        }
    }

    public static ReportDocTypeEnum getReportDocTypeEnumByVal(String code) {
        return Arrays.stream(ReportDocTypeEnum.values())
                .collect(Collectors.toMap(ReportDocTypeEnum::getCode, value -> value, (k1, k2) -> k2)).get(code);
    }

    public static ReportDocTypeEnum getReportDocTypeEnumByCode1(int code1) {
        return Arrays.stream(ReportDocTypeEnum.values())
                .collect(Collectors.toMap(ReportDocTypeEnum::getCode1, value -> value, (k1, k2) -> k2)).get(code1);
    }
}
